package com.example.wananrdroid.fragment.zhufragment;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.example.wananrdroid.R;
import com.example.wananrdroid.adapter.Vpadapter;
import com.example.wananrdroid.fragment.zhufragment.tixi.DaohangFragment;
import com.example.wananrdroid.fragment.zhufragment.tixi.TiFragment;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;

/**
 * A simple {@link Fragment} subclass.
 */
public class TixiFragment extends Fragment {


    private ViewPager mTiVp;
    private TabLayout mTiTab;
    private Toolbar mTiToolbar;

    public TixiFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_tixi, container, false);
        initViews(view);
        return view;
    }

    private void initViews(View view) {
        mTiVp = view.findViewById(R.id.ti_vp);
        mTiTab = view.findViewById(R.id.ti_tab);
        mTiToolbar = view.findViewById(R.id.ti_toolbar);
        mTiToolbar.setTitle("");
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(new TiFragment());
        fragments.add(new DaohangFragment());
        Vpadapter vpadapter = new Vpadapter(getChildFragmentManager(), fragments);
        mTiVp.setAdapter(vpadapter);
        mTiTab.setupWithViewPager(mTiVp);
        mTiTab.getTabAt(0).setText("体系");
        mTiTab.getTabAt(1).setText("导航");

    }
}
